From 49917db5e9842a569854d34cabf8436285fdde69 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 13 Sep 2005 21:29:28 +0000 Subject: [PATCH] Perform xenbus operations in shutdown_handler in a transaction. Signed-off-by: Christian Limpach --- linux-2.6-xen-sparse/arch/xen/kernel/reboot.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c index b6608cef49..12c7610e90 100644 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c @@ -320,20 +320,28 @@ static void __shutdown_handler(void *unused) static void shutdown_handler(struct xenbus_watch *watch, const char *node) { static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL); - char *str; + int err; + again: + err = xenbus_transaction_start("control"); + if (err) + return; str = (char *)xenbus_read("control", "shutdown", NULL); - /* Ignore read errors. */ - if (IS_ERR(str)) - return; - if (strlen(str) == 0) { - kfree(str); - return; + /* Ignore read errors and empty reads. */ + if (XENBUS_IS_ERR_READ(str)) { + xenbus_transaction_end(1); + return; } xenbus_write("control", "shutdown", "", O_CREAT); + err = xenbus_transaction_end(0); + if (err == -ETIMEDOUT) { + kfree(str); + goto again; + } + if (strcmp(str, "poweroff") == 0) shutting_down = SHUTDOWN_POWEROFF; else if (strcmp(str, "reboot") == 0) -- 2.30.2